<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .div1>.div2 {
      width: 20%;
      height: 0;
      padding-bottom: 20%;
      /* 利用 padding-bottom 来确保高度和宽度相等，形成正方形 */
      background-color: #4CAF50;
      color: white;
      border: none;
      border-radius: 5px;
      cursor: pointer;
      font-size: 14px;
      display: flex;
      align-items: center;
      justify-content: center;
      text-align: center;
    }
  </style>
</head>

<body>
  <div class="div1">
    <div class="div2"></div>
  </div>
</body>

</html>